package com.kedacom.freedomLabel.initdata.bean;


import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.kedacom.freedomLabel.model.bean.IFirstLetter;
import com.kedacom.freedomLabel.model.bean.IMainSelectItem;
import com.kedacom.freedomLabel.utils.Cn2Spell;

/**
 * Created by yao on 2021/3/23.
 * Describe
 */
@Entity
public class NewProduct extends IFirstLetter implements IMainSelectItem {

    @NonNull
    @PrimaryKey(autoGenerate = true)
    private long id;
    private String gridId;
    private String gridCode;
    private String gridName;
    private String memo;

    @NonNull
    public long getId() {
        return id;
    }

    public void setId(@NonNull long id) {
        this.id = id;
    }

    public String getGridId() {
        return gridId;
    }

    public void setGridId(String gridId) {
        this.gridId = gridId;
    }

    public String getGridCode() {
        return gridCode;
    }

    public void setGridCode(String gridCode) {
        this.gridCode = gridCode;
    }

    public String getGridName() {
        return gridName;
    }

    public void setGridName(String gridName) {
        this.gridName = gridName;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    @Override
    public String toString() {
        return "Product{" +
                "gridId='" + gridId + '\'' +
                ", gridCode='" + gridCode + '\'' +
                ", gridName='" + gridName + '\'' +
                ", memo='" + memo + '\'' +
                '}';
    }

    @Override
    public String getFirstLetter() {
        if (TextUtils.isEmpty(this.gridName)) {
            return "#";
        }
        String firstLetter = Cn2Spell.getPinYin(this.gridName).substring(0, 1).toUpperCase();
        if (!firstLetter.matches("[A-Z]")) {
            return "#";
        }
        return firstLetter;
    }
    @Override
    public String getItemName() {
        return this.gridName;
    }

    @Override
    public String[] getSelectResultData() {
        return new String[]{this.gridId, this.gridName};
    }

}
